package fr.aracore.domotique.zapi.event;

import java.util.Observable;

import fr.aracore.domotique.zapi.core.ZbResponse;

public class ZbEvent extends Observable{
	public static final String PREFIX="Received radio ID ";
	public ZbResponse response;
	
	public ZbEvent(ZbResponse response){
		super();
		this.response=response;
		setChanged();
	}
	//Used for test
	public ZbEvent(String message){
		super();
		this.response=new ZbResponse();
		this.response.message=message;
		setChanged();
	}
	public String toString(){
		return "ZbEvent :\n"+response;
	}
	
	public String id(){
		String lcMessage=response.message;
		int lcIndexDebut=lcMessage.indexOf("<id>");
		if (lcIndexDebut!=-1){
			return lcMessage.substring(lcIndexDebut+4,lcMessage.indexOf("</id>"));
		}
		return null;
	}

	
}
